@extends('manager._layouts.default')

@section('main')

    <h2>Edit page</h2>

    {{ Notification::showAll() }}

    {{ Form::model($page,
        array(
            'method' => 'put',
            'route' => array('manager.pages.update', $page->id)
        ))
    }}
        {{ Form::hidden('parentid', $page->parentid) }}

        <div class="row">
            <div class="row col-lg-12">
                <div class="form-group col-lg-6">
                    <label for="name">Page Name</label>
                    <input type="text" id="name" name="name" value="<?=$page->name?>" class="form-control">
                </div>
                <div class="form-group col-lg-3">
                    <label for="slug">Slug</label>
                    <i class="fa fa-fw fa-question-circle help" data-toggle="popover" data-placement="right" data-trigger="hover" data-content="This is the friendly URL of the page" data-container="body"></i>
                    <input type="text" id="slug" name="slug" value="<?=$page->slug?>" class="form-control">
                </div>
            </div>
        </div>

        <ul class="nav nav-tabs">
            <li class="active"><a href="#content" data-toggle="tab">Content</a></li>
            <li><a href="#general" data-toggle="tab">General Settings</a></li>
            <li><a href="#seo" data-toggle="tab">SEO</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="content">
	            <script id="tmpl_page_row" type="text/x-jsrender">
		            {^{for rows}}
		                <div class="page_row row clearfix" data-link="data-index{:#index}">
							{^{for blocks}}
								<div class="" data-link="class{:'page_row_block col-lg-'+span+' col-lg-offset-'+offset} data-index{:#index} data-span{:span} data-offset{:offset}">
									<div class="clearfix">
										<div class="btn-group pull-left">
											<a href="#" class="btn btn-xs btn-default decrease-left-margin" data-toggle="tooltip" data-placement="top" title="Push left"><i class="fa fa-fw fa-angle-left"></i></a>
											<a href="#" class="btn btn-xs btn-default decrease-span" data-toggle="tooltip" data-placement="top" title="Decrease width"><i class="fa fa-fw fa-angle-double-left"></i></a>
											<a href="#" class="btn btn-xs btn-default increase-span" data-toggle="tooltip" data-placement="top" title="Increase width"><i class="fa fa-fw fa-angle-double-right"></i></a>
											<a href="#" class="btn btn-xs btn-default increase-left-margin" data-toggle="tooltip" data-placement="top" title="Push right"><i class="fa fa-fw fa-angle-right"></i></a>
										</div>
										<div class="pull-right">
											<span class="label label-info" data-toggle="tooltip" data-placement="top" title="Max span 12">Span: {^{:span}}</span>
											<span class="label label-info">Offset: {^{:offset}}</span>
											<a href="#" class="btn btn-xs btn-danger delete-block" data-toggle="tooltip" data-placement="top" title="Delete block"><i class="fa fa-fw fa-trash-o"></i></a>
										</div>
									</div>
									<textarea class="editor" id="">{^{:content}}</textarea>
								</div>
							@{{/for}}
						</div>
		                <div class="clearfix page_row_controls">
							<a href="#" class="btn btn-sm btn-primary addblockbutton"><i class="fa fa-fw fa-plus"></i> Add Block</a>
							<a href="#" class="btn btn-sm btn-danger deleterowbutton"><i class="fa fa-fw fa-trash-o"></i> Remove Row</a>
						</div>
		            @{{/for}}
	            </script>

	            <div id="pagecontent" class="container_fluid"></div>

	            <p><button class="btn btn-primary btn-lg btn-block" id="addrowbutton"><i class="fa fa-plus"></i> Add Row</button></p>

	            <input type="hidden" name="page_content" id="page_content" value="">

	            <script>
		            page_content = {{ $paqe_content }};
	            </script>
            </div>
            <div class="tab-pane" id="general">
                <div class="row">
                    <div class="form-group col-lg-4">
                        <label for="pagetemplateid">Template</label>
                        {{ Form::select('pagetemplateid', $page_templates, $page->pagetemplateid, array("class"=>"form-control input-sm")) }}
                    </div>
                </div>
                <div class="row">
                    <div class="form-group col-lg-4">
                        <label for="status">Status</label>
                        {{ Form::select('status', array("0" => "Hidden", "1" => "Active"), $page->status, array("class"=>"form-control input-sm")) }}
                    </div>
                </div>
            </div>
            <div class="tab-pane" id="seo">
                <div class="row">
                    <div class="form-group col-lg-6">
                        <label for="title">Title</label>
                        <input type="text" id="title" name="title" value="<?=$page->title?>" class="form-control">
                    </div>

                    <div class="form-group col-lg-6">
                        <label for="keywords">Keywords</label>
                        <input type="text" id="keywords" name="keywords" value="<?=$page->keywords?>" class="form-control input-sm">
                    </div>
                </div>
                <div class="row">
                    <div class="form-group col-lg-12">
                        <label for="description">Description</label>
                        <textarea name="description" class="form-control input-sm"><?=$page->description?></textarea>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-lg-12">
                <button type="submit" class="btn btn-primary btn-large">Save</button>
                <a href="{{ URL::route('manager.pages.index') }}" class="btn btn-default btn-large">Cancel</a>
            </div>

        </div>

    {{ Form::close() }}

@stop